#include "sfsis.h"
#include "helper.h"
/**/
static InAnimation_Types currentInAnimationType = IN_ANIMATION_FADE;

/*渐变效果*/
typedef struct
{
    Helper_EaseInEaseOut_Context easeFade;
} inAnimationFade_Context;
static inAnimationFade_Context in_fadeContext;

void inAnimationFade_Restart(void)
{
    in_fadeContext.easeFade.key = 0;
    in_fadeContext.easeFade.target = 0xff;
}

Efct_Stage inAnimationFade(void)
{
    su16 tmp = 0;
    helper_easeInEaseOutGenerate(&in_fadeContext.easeFade);
    for (tmp = 0; tmp < gCfgFactoryPtr->enabledDotNumber; tmp++)
    {
        rgbStrip.rgbMemory[tmp][0] = helper_cacl_precentage_denoinator255(rgbStrip.rgbMemory[tmp][0], in_fadeContext.easeFade.key);
        rgbStrip.rgbMemory[tmp][1] = helper_cacl_precentage_denoinator255(rgbStrip.rgbMemory[tmp][1], in_fadeContext.easeFade.key);
        rgbStrip.rgbMemory[tmp][2] = helper_cacl_precentage_denoinator255(rgbStrip.rgbMemory[tmp][2], in_fadeContext.easeFade.key);
    }

    if (in_fadeContext.easeFade.key == in_fadeContext.easeFade.target)
    {
        return E_FINISHED;
    }
    else
    {
        return E_PROCESS;
    }
}

void inAnimationRestart(InAnimation_Types inType)
{
    currentInAnimationType = inType;
    switch (inType)
    {
    case IN_ANIMATION_FADE:
        inAnimationFade_Restart();
        break;
    default:
        break;
    }
}

Efct_Stage inAnimation(void)
{
    Efct_Stage ret = E_FINISHED;
    switch (currentInAnimationType)
    {
    case IN_ANIMATION_FADE:
        ret = inAnimationFade();
        break;
    default:
        ret = inAnimationFade();
        break;
    }
    return ret;
}